<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateMemberTable extends AbstractMigration
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $item = $this->table('member', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci','comment' => '成员表']);

        $item->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('type', 'enum', ['values' => 'knowledge,book,chat','default' => 'knowledge', 'null' => false,'comment' => '团队类型:知识库,知识本,会话文档'])
            ->addColumn('role', 'enum', ['values' => 'super_admin,admin,editor,viewer', 'default' => 'super_admin', 'null' => false, 'comment' => '角色类型:超级管理员(创建者),管理员,编辑人员,普通人员'])
            ->addColumn('user_id', 'integer', ['default' => 0, 'limit' => 11, 'comment' => '用户id'])
            ->addColumn('type_id', 'integer', ['default' => 0, 'limit' => 11, 'comment' => '团队类型id'])
            ->addColumn('created', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'comment' => '创建时间'])
            ->addColumn('updated', 'integer',  ['limit' => 11, 'null' => true, 'default' => 0, 'comment' => '更新时间'])
            ->addColumn('tenant_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '租户ID'])
            ->save();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $this->dropTable('member');
    }
}
